﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace 单例模式
{

    /// <summary>
    /// 单线程使用
    /// </summary>
    class SingleThread_Singleton
    {
        /// <summary>
        /// 创建此类私有静态实例
        /// </summary>
        private static SingleThread_Singleton instance = null;

        /// <summary>
        /// 私有构造函数
        /// </summary>
        private SingleThread_Singleton()
        {

        }

        /// <summary>
        /// 创建全局访问点   get 只读
        /// </summary>
        public static SingleThread_Singleton Instance
        {

            get
            {
                if (instance == null)   //多线程无法判断 此类 是否为空
                {
                    instance = new SingleThread_Singleton();
                }

                return instance;
            }
        }

    }
}
